function r = fixErrRate(c, p)
  r = c;
  errPos = find(rand(c) < p);
  r(errPos) = 1 - c(errPos);
endfunction
